import java.util.Arrays;

public class Solution {
    public static int findNumberOfLIS(int[] nums) {
        int n = nums.length;

        //以i为结尾的最长递增子序列的长度
        int[] len = new int[n];

        //len[i]的个数
        int[] count = new int[n];

        //初始化
        for (int i = 0; i < n; i++) {
            len[i] = 1;
            count[i] = 1;
        }

        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    if (len[i] == len[j] + 1) {
                        count[i] += count[j];
                    } else if (len[i] < len[j] + 1) {
                        count[i] = count[j];
                        len[i] = len[j] + 1;
                    }
                }
            }
        }

        System.out.println(Arrays.toString(len));
        System.out.println(Arrays.toString(count));

        int ret = count[0];
        int max = len[0];
        for (int i = 1; i < n; i++) {
            if (max == len[i]) {
                ret += count[i];
            } else if (max < len[i]) {
                ret = count[i];
                max = len[i];
            }
        }

        return ret;
    }

    public static void main(String[] args) {
        System.out.println(findNumberOfLIS(new int[]{1, 3, 2}));
    }
}
